namespace SubSonic
{
    using System;
    using System.Data;

    [Serializable]
    public class ReadOnlyList<ItemType, ListType> : AbstractList<ItemType, ListType> where ItemType: ReadOnlyRecord<ItemType>, new() where ListType: AbstractList<ItemType, ListType>, new()
    {
        public ReadOnlyList()
        {
        }

        public ReadOnlyList(IDataReader rdr)
        {
            base.Load(rdr);
        }

        public ReadOnlyList(IDataReader rdr, bool closeReader)
        {
            base.Load(rdr);
            if (closeReader)
            {
                rdr.Close();
            }
        }

        public ReadOnlyList<ItemType, ListType> Clone()
        {
            ReadOnlyList<ItemType, ListType> list = new ReadOnlyList<ItemType, ListType>();
            foreach (ItemType local in this)
            {
                ItemType item = local.Clone();
                list.Add(item);
            }
            return list;
        }
    }
}

